
var isplaying = false;
var nowplaying = 0;
var cannext    = true;
window.onload  = function () {
    let sound = document.getElementById("sound");
    let say   = document.getElementById("say");
    let body = document.getElementsByClassName("info_text")[0];

    let mycontent = [

        "不知不觉，人生或许已经过了1/4",
        "仿佛弹指瞬间，我们生命又画上了一道年轮",
        "一个人的青涩到成熟，除了自身的修炼",
        "还必须有时光的打磨，岁月的锻造",
        "岁月让我们学会了世事洞明随遇而安",
        "学会了豁达和感恩，更加善待自己",
        "更加珍惜每一份感情",
        "更加热爱自己的生活",
        "同时学会了包容，担当，疗伤，选择和放弃",
        ".....",
        "...",
        "..",
        ".",
        "马美妮，我喜欢你",
        "现在喜欢",
        "以后也喜欢",
        "希望能与你，看潮起潮落，云卷云疏",
    ];

    say.innerText = mycontent[nowplaying];

    body.addEventListener('mousedown', function(){

        if(isplaying == false){
            sound.muted = false;
            sound.volume = 0.4;
            sound.play();
            isplaying = true;
        }else{

            if(cannext == false){
                return;
            }
            cannext = false;
            nowplaying ++;

            if(nowplaying >=9 && nowplaying<=12  ){

                document.body.className = "html"
            }else{
                document.body.className = ""
            }

            if(nowplaying >= mycontent.length ){
                say.innerText = "";
                return;
            }
            let content = mycontent[nowplaying];
            let index = -1;
            let str   = "";

            let timer = setInterval(()=>{
                index ++;
                if(index >= content.length){
                    clearInterval(timer);
                    cannext = true;
                    return;
                }
                str +=content[index];
                say.innerText = str;

            },120);
        }
    }, false);
}